/*   1:    */ package com.atomikos.datasource.xa;
/*   2:    */ 
/*   3:    */ import java.io.PrintWriter;
/*   4:    */ import javax.transaction.xa.XAException;
/*   5:    */ import javax.transaction.xa.XAResource;
/*   6:    */ import javax.transaction.xa.Xid;
/*   7:    */ 
/*   8:    */ public class LoggingXAResource
/*   9:    */   implements XAResource
/*  10:    */ {
/*  11:    */   private PrintWriter writer_;
/*  12:    */   private XAResource xares_;
/*  13:    */   
/*  14:    */   public LoggingXAResource(XAResource xares, PrintWriter writer)
/*  15:    */   {
/*  16: 60 */     this.xares_ = xares;
/*  17: 61 */     this.writer_ = writer;
/*  18:    */   }
/*  19:    */   
/*  20:    */   private void log(String msg, XAException error)
/*  21:    */   {
/*  22: 66 */     if (this.writer_ != null) {
/*  23: 67 */       this.writer_.println("XAResource: " + msg + ": " + error.toString() + " errorCode " + error.errorCode);
/*  24:    */     }
/*  25:    */   }
/*  26:    */   
/*  27:    */   private void log(String msg)
/*  28:    */   {
/*  29: 74 */     if (this.writer_ != null) {
/*  30: 75 */       this.writer_.println("XAResource: " + msg);
/*  31:    */     }
/*  32:    */   }
/*  33:    */   
/*  34:    */   public Xid[] recover(int flag)
/*  35:    */     throws XAException
/*  36:    */   {
/*  37: 85 */     Xid[] ret = null;
/*  38:    */     try
/*  39:    */     {
/*  40: 88 */       log("Enter recover");
/*  41: 89 */       ret = this.xares_.recover(flag);
/*  42: 90 */       log("Exit recover");
/*  43:    */     }
/*  44:    */     catch (XAException e)
/*  45:    */     {
/*  46: 92 */       log("Error in recover", e);
/*  47: 93 */       throw e;
/*  48:    */     }
/*  49: 96 */     return ret;
/*  50:    */   }
/*  51:    */   
/*  52:    */   public boolean setTransactionTimeout(int secs)
/*  53:    */     throws XAException
/*  54:    */   {
/*  55:105 */     boolean ret = false;
/*  56:    */     try
/*  57:    */     {
/*  58:108 */       log("Enter setTransactionTimeout");
/*  59:109 */       ret = this.xares_.setTransactionTimeout(secs);
/*  60:110 */       log("Exit setTransactionTimeout with return value " + ret);
/*  61:    */     }
/*  62:    */     catch (XAException e)
/*  63:    */     {
/*  64:112 */       log("Error in setTransactionTimeout", e);
/*  65:113 */       throw e;
/*  66:    */     }
/*  67:116 */     return ret;
/*  68:    */   }
/*  69:    */   
/*  70:    */   public int getTransactionTimeout()
/*  71:    */     throws XAException
/*  72:    */   {
/*  73:125 */     int ret = -1;
/*  74:    */     try
/*  75:    */     {
/*  76:128 */       log("Enter getTransactionTimeout");
/*  77:129 */       ret = this.xares_.getTransactionTimeout();
/*  78:130 */       log("Exit getTransactionTimeout with return value " + ret);
/*  79:    */     }
/*  80:    */     catch (XAException e)
/*  81:    */     {
/*  82:132 */       log("Error in getTransactionTimeout", e);
/*  83:133 */       throw e;
/*  84:    */     }
/*  85:136 */     return ret;
/*  86:    */   }
/*  87:    */   
/*  88:    */   public boolean isSameRM(XAResource xares)
/*  89:    */     throws XAException
/*  90:    */   {
/*  91:145 */     boolean ret = false;
/*  92:    */     try
/*  93:    */     {
/*  94:148 */       log("Enter isSameRM");
/*  95:149 */       ret = this.xares_.isSameRM(xares);
/*  96:150 */       log("Exit isSameRM with return value " + ret);
/*  97:    */     }
/*  98:    */     catch (XAException e)
/*  99:    */     {
/* 100:152 */       log("Error in isSameRM", e);
/* 101:153 */       throw e;
/* 102:    */     }
/* 103:156 */     return ret;
/* 104:    */   }
/* 105:    */   
/* 106:    */   public void start(Xid xid, int flags)
/* 107:    */     throws XAException
/* 108:    */   {
/* 109:    */     try
/* 110:    */     {
/* 111:166 */       log("Enter start for xid " + xid.toString());
/* 112:167 */       this.xares_.start(xid, flags);
/* 113:168 */       log("Exit start");
/* 114:    */     }
/* 115:    */     catch (XAException e)
/* 116:    */     {
/* 117:170 */       log("Error in start", e);
/* 118:171 */       throw e;
/* 119:    */     }
/* 120:    */   }
/* 121:    */   
/* 122:    */   public void end(Xid xid, int flags)
/* 123:    */     throws XAException
/* 124:    */   {
/* 125:    */     try
/* 126:    */     {
/* 127:183 */       log("Enter end for xid " + xid.toString());
/* 128:184 */       this.xares_.end(xid, flags);
/* 129:185 */       log("Exit end");
/* 130:    */     }
/* 131:    */     catch (XAException e)
/* 132:    */     {
/* 133:187 */       log("Error in end", e);
/* 134:188 */       throw e;
/* 135:    */     }
/* 136:    */   }
/* 137:    */   
/* 138:    */   public int prepare(Xid xid)
/* 139:    */     throws XAException
/* 140:    */   {
/* 141:199 */     int ret = -1;
/* 142:    */     try
/* 143:    */     {
/* 144:201 */       log("Enter prepare for xid " + xid.toString());
/* 145:202 */       ret = this.xares_.prepare(xid);
/* 146:203 */       log("Exit prepare with return value " + ret);
/* 147:    */     }
/* 148:    */     catch (XAException e)
/* 149:    */     {
/* 150:205 */       log("Error in prepare", e);
/* 151:206 */       throw e;
/* 152:    */     }
/* 153:209 */     return ret;
/* 154:    */   }
/* 155:    */   
/* 156:    */   public void rollback(Xid xid)
/* 157:    */     throws XAException
/* 158:    */   {
/* 159:    */     try
/* 160:    */     {
/* 161:219 */       log("Enter rollback for xid " + xid.toString());
/* 162:220 */       this.xares_.rollback(xid);
/* 163:221 */       log("Exit rollback");
/* 164:    */     }
/* 165:    */     catch (XAException e)
/* 166:    */     {
/* 167:223 */       log("Error in rollback", e);
/* 168:224 */       throw e;
/* 169:    */     }
/* 170:    */   }
/* 171:    */   
/* 172:    */   public void commit(Xid xid, boolean onephase)
/* 173:    */     throws XAException
/* 174:    */   {
/* 175:    */     try
/* 176:    */     {
/* 177:236 */       log("Enter commit for xid " + xid.toString());
/* 178:237 */       this.xares_.commit(xid, onephase);
/* 179:238 */       log("Exit commit");
/* 180:    */     }
/* 181:    */     catch (XAException e)
/* 182:    */     {
/* 183:240 */       log("Error in commit", e);
/* 184:241 */       throw e;
/* 185:    */     }
/* 186:    */   }
/* 187:    */   
/* 188:    */   public void forget(Xid xid)
/* 189:    */     throws XAException
/* 190:    */   {
/* 191:    */     try
/* 192:    */     {
/* 193:253 */       log("Enter forget for xid " + xid.toString());
/* 194:254 */       this.xares_.forget(xid);
/* 195:255 */       log("Exit forget");
/* 196:    */     }
/* 197:    */     catch (XAException e)
/* 198:    */     {
/* 199:257 */       log("Error in forget", e);
/* 200:258 */       throw e;
/* 201:    */     }
/* 202:    */   }
/* 203:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions-jta\3.7.0\transactions-jta-3.7.0.jar
 * Qualified Name:     com.atomikos.datasource.xa.LoggingXAResource
 * JD-Core Version:    0.7.0.1
 */